//
//  ViewController.swift
//  1.18.Creating Scrollable Content with UIScrollView
//
//  Created by joker on 15/7/22.
//  Copyright (c) 2015年 joker. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UIScrollViewDelegate {

    var imageView: UIImageView!
    var scrollView: UIScrollView!
    let image = UIImage(named: "Safari")
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        imageView = UIImageView(image: image)
        
        scrollView = UIScrollView(frame: view.bounds)
        
        scrollView.contentSize = imageView.bounds.size
        scrollView.addSubview(imageView)
        scrollView!.delegate = self
        scrollView.indicatorStyle = .White
        view.addSubview(scrollView)
    }
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        scrollView.alpha = 0.5
    }
    
    func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        scrollView.alpha = 1.0
    }
    
    func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        scrollView.alpha  = 1
    }
}

